<?php
namespace Home\Controller;
use Think\Controller;
class ZhuceController extends HomeController
{
	public function index()
	{
		$this->display();
	}
	public function zhuce()
	{
		// 判断手机验证码
		if(I('post.syzm')!=6532){
			$this->error("手机验证码错误！");exit;
		}
		// 判断用户名是否被使用
		$b=M('user')->where(array('name'=>I('post.name')))->find();
		if(I('post.name')==$b['name']){
			$this->error("用户名已存在");exit;
		}
		// 执行添加用户
		$add['jid']=1;
		M('user')->create();
		M('user')->add();
		$a=M('user')->where(array('name'=>I('post.name')))->find();
		$add['uid']=$a['id'];
		if(M('uj')->add($add) > 0){
			$this->success("注册成功！",U('login/index'));
		}else{
			$this->error("注册失败！");
		}
	}
	public function ajax()
	{
		// echo I('post.phone');exit;
		include "./duanxinyanzheng/SendTemplateSMS.php";
		sendTemplateSMS(I('post.phone'),array('6532','5'),"1");//手机号码，替换内容数组，模板ID
		$this->ajaxReturn(1);
	}

	public function _empty($name)
    {
        // echo '<h1>404</h1>';
        $this->display('Empty/404');
    }
}